#include "EquationSolver.hpp"
#include <iostream>
#include <iomanip>

using namespace std; 

class F : public Function{
public:
    double operator() (double x) const{
        return 10*(0.5*M_PI-asin(x)-x*sqrt(1-x*x))-12.4;
    }
    double derivative(double x) const{
        return -10*(2*sqrt(1-x*x));
    }
}f;

void solve_F1() {
    cout << "Solving depth of water with Bisection_Method" << endl;
    Bisection_Method solver_f1(F(),-1,1);
    double x = solver_f1.solve();
    cout << "A root is :" << fixed << setprecision(2) << x << endl;
    cout << "Error is :" << scientific << f(x) << endl;
}

void solve_F2() {
    cout << "Solving depth of water with Newton_Method" << endl;
    Newton_Method solver_f2(F(),0.2);
    double x = solver_f2.solve();
    cout << "A root is :" << fixed << setprecision(2) << x << endl;
    cout << "Error is :" << scientific << f(x) << endl;
}

void solve_F3() {
    cout << "Solving depth of water with Secant_Method" << endl;
    Secant_Method solver_f3(F(),0,0.5);
    double x = solver_f3.solve();
    cout << "A root is :" << fixed << setprecision(2) << x << endl;
    cout << "Error is :" << scientific << f(x) << endl;
}

int main() {
    solve_F1();
    solve_F2();
    solve_F3();
    return 0;
}